//
//  FootView.m
//  Game2048
//
//  Created by mis on 16/3/22.
//  Copyright © 2016年 mis. All rights reserved.
//

#import "FootView.h"

@interface FootView ()
@property (nonatomic, strong) UIView *currentScoreBackground;
@property (nonatomic, strong) UILabel *currentScoreHing;
@property (nonatomic, strong) UILabel *currentScoreLB;
@property (nonatomic, strong) UIView *highScoreBackground;
@property (nonatomic, strong) UILabel *highScoreHing;
@property (nonatomic, strong) UILabel *highScoreLB;
@end

@implementation FootView

#pragma mark - lazy load
- (UIView *)currentScoreBackground {
    if (!_currentScoreBackground) {
        _currentScoreBackground = [[UIView alloc] initWithFrame:CGRectMake(10, 10, 150, 80)];
        _currentScoreBackground.clipsToBounds = YES; // 允许修改形状
        _currentScoreBackground.layer.cornerRadius = 5; // 圆角弧度
        _currentScoreBackground.layer.masksToBounds = YES;
        _currentScoreBackground.backgroundColor = [UIColor darkGrayColor];
    }
    return _currentScoreBackground;
}

- (UIView *)highScoreBackground {
    if (!_highScoreBackground) {
        _highScoreBackground = [[UIView alloc] initWithFrame:CGRectMake(self.frame.size.width - 160, 10, 150, 80)];
        _highScoreBackground.clipsToBounds = YES; // 允许修改形状
        _highScoreBackground.layer.cornerRadius = 5; // 圆角弧度
        _highScoreBackground.backgroundColor = [UIColor darkGrayColor];
    }
    return _highScoreBackground;
}

- (UILabel *)currentScoreHing {
    if (!_currentScoreHing) {
        _currentScoreHing = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, 150, 40)];
        _currentScoreHing.textAlignment = NSTextAlignmentCenter;
        _currentScoreHing.font = [UIFont fontWithName:@"BradleyHandITCTT-Bold" size:20];
        _currentScoreHing.textColor = [UIColor whiteColor];
        _currentScoreHing.text = @"CurrentScore";
    }
    return _currentScoreHing;
}

- (UILabel *)currentScoreLB {
    if (!_currentScoreLB) {
        _currentScoreLB = [[UILabel alloc] initWithFrame:CGRectMake(10, 50, 150, 40)];
        _currentScoreLB.textAlignment = NSTextAlignmentCenter;
        _currentScoreLB.font = [UIFont fontWithName:@"BradleyHandITCTT-Bold" size:20];
        _currentScoreLB.textColor = [UIColor whiteColor];
    }
    return _currentScoreLB;
}

- (UILabel *)highScoreHing {
    if (!_highScoreHing) {
        _highScoreHing = [[UILabel alloc] initWithFrame:CGRectMake(self.frame.size.width - 160, 10, 150, 40)];
        _highScoreHing.textAlignment = NSTextAlignmentCenter;
        _highScoreHing.font = [UIFont fontWithName:@"BradleyHandITCTT-Bold" size:20];
        _highScoreHing.textColor = [UIColor whiteColor];
        _highScoreHing.text = @"HighScore";
    }
    return _highScoreHing;
}

- (UILabel *)highScoreLB {
    if (!_highScoreLB) {
        _highScoreLB = [[UILabel alloc] initWithFrame:CGRectMake(self.frame.size.width - 160, 50, 150, 40)];
        _highScoreLB.textAlignment = NSTextAlignmentCenter;
        _highScoreLB.textColor = [UIColor whiteColor];
        _highScoreLB.font = [UIFont fontWithName:@"BradleyHandITCTT-Bold" size:20];
    }
    return _highScoreLB;
}

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        self.frame = frame;
        [self addSubview:self.currentScoreBackground];
        [self addSubview:self.highScoreBackground];
        [self addSubview:self.currentScoreHing];
        [self addSubview:self.currentScoreLB];
        [self addSubview:self.highScoreHing];
        [self addSubview:self.highScoreLB];
    }
    return self;
}

- (void)setHighScore:(UInt32)score {
    self.highScoreLB.text = [NSString stringWithFormat:@"%u",score];
}

- (void)setCurrentScore:(UInt32)score {
    self.currentScoreLB.text = [NSString stringWithFormat:@"%u",score];
}

@end
